package com.hsy.crm.web.web;

import com.hsy.crm.web.domain.entity.Product;
import com.hsy.crm.web.service.impl.ProductService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/demo")
public class DemoAction {

    Logger logger = LoggerFactory.getLogger(DemoAction.class);

    @Autowired
    ProductService productService;

    @Resource(name="xxxRedisTemplate")
    RedisTemplate<String, DemoVo> redisTemplate;

    @RequestMapping("/redis")
    public String index() {
        logger.info("start redis test");
        List<Product> productList = productService.selectAll();
        DemoVo demoVo = new DemoVo();
        demoVo.setProductList(productList);
        redisTemplate.opsForValue().set("demoVo",demoVo);
        logger.info("redis test end");
        return "ok";
    }

}
